// named_pipe_writer.c
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <string.h> // 添加缺失的头文件

int main() {
    const char *fifo = "/tmp/myfifo";
    mkfifo(fifo, 0666); // 创建命名管道

    int fd = open(fifo, O_WRONLY);
    if (fd == -1) {
        perror("open");
        return 1;
    }

    write(fd, "Hello from writer", strlen("Hello from writer"));
    close(fd);

    return 0;
}

